{% form_theme form '::fields2tab.html.twig' %}
<div class="contentwrapper">
    <div class="heading">
        <h3>Nouveau Client</h3>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <form id="form_client" action="" {{ form_enctype(form) }} method="POST" class="form-horizontal seperator">
                    {{ form_row(form.code,{'attr':{'readonly':'readonly'}}) }}
                {{ form_row(form.raison_social) }}
                    {{ form_row(form.matricule_fiscale) }}
                    {{ form_row(form.tel) }}
                    {{form_row(form.gsm)}}
                    {{form_row(form.fax)}}

                    {{ form_row(form.solde) }}
                    {{ form_row(form.limite_credit) }}
                    {{ form_row(form.numero_exonoration) }}
                    {{form_row(form.adresse)}}
                    {{ form_row(form._token) }}
                <div style="float: left;width: 90%" class="form-actions">
                    <button onclick="saveClient('n')" class="btn btn-info" type="button">Enregistrer et Nouveau</button>
                    <button onclick="saveClient('f')" class="btn btn-info" type="button">Enregistrer et Fermer</button>
                    <button onclick="listClient()" class="btn" type="button">Retour vers liste</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $('#gds_ventebundle_clienttype_solde').spinner({
        step: 1,
        places: 3,
        showOn: 'both'
    });
    $('#gds_ventebundle_clienttype_limite_credit').spinner({
        step: 1,
        places: 3,
        showOn: 'both'
    });
    function saveClient(red) {
        var data = $('#form_client').serialize()
        if ($('#form_client').valid()) {
            $.ajax({
                type: 'post',
                url: '{{ path('gds_client_new') }}',
                data: data + '&red=' + red,
                success: function(data) {
                    $('#div_client').html(data)
                }
            })
        }
    }
    function listClient() {
        $.ajax({
            type: 'post',
            url: '{{ path('gds_client_list') }}',
            success: function(data) {
                $('#div_client').html(data)
            }
        })
    }
</script>